package com.world.tg.service.impl;

import com.world.tg.anno.CacheFind;
import com.world.tg.dao.DetailDao;
import com.world.tg.dao.SellerDao;
import com.world.tg.pojo.BookMessage;
import com.world.tg.result.JsonResult;
import com.world.tg.service.DetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DetailServiceImpl implements DetailService {

    @Autowired
    DetailDao detailDao;

    @Autowired
    SellerDao sellerDao;

    @Override
    public JsonResult findBookByBid(Integer bid) {

        JsonResult jsonResult = new JsonResult();
        jsonResult.success("success",detailDao.findByBid(bid));
        return jsonResult;
    }

    @Override
    public JsonResult findSeller(Integer sid) {
        JsonResult jsonResult = new JsonResult();
        jsonResult.success("success",sellerDao.getSName(sid));
        return jsonResult;
    }

    @Override
    public JsonResult findComment(Integer bid) {
        JsonResult jsonResult = new JsonResult();
        jsonResult.success("success",detailDao.findComment(bid));
        return jsonResult;
    }

    @Override
    @CacheFind(key = "bookParam")
    public JsonResult findBookParam(Integer bid) {
        JsonResult jsonResult = new JsonResult();
        BookMessage param = detailDao.findParam(bid);
        jsonResult.success("success",param);
        return jsonResult;
    }

}
